#ifndef IMAGEMODEL2_H
#define IMAGEMODEL2_H

#include <QDir>
#include <QAbstractListModel>
#include "ImageLabelModel.h"
#include "BaseResult.h"

class ImageModel2 : public QAbstractListModel {
Q_OBJECT

public:
    //饱汉式，线程不安全
     static ImageModel2* getInstance() {
         if(instance == nullptr) {
            instance = new ImageModel2();
         }
        return instance;
    }
    explicit ImageModel2(QObject *parent = nullptr);
    ~ImageModel2();

    int rowCount(const QModelIndex &parent = QModelIndex()) const override;
    QVariant data(const QModelIndex &index, int role = 1) const override;


    Q_INVOKABLE BaseResult::JsonResult openDir(QString dir);
    int count() const;

protected:
    virtual QHash<int, QByteArray> roleNames() const;

private:
    static ImageModel2* instance;
    QList<ImageLabelModel> _dataList_;
    QString dir;

};


#endif // IMAGEMODEL2_H
